package com.kifas.entity;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 * @author brainmaster
 * 
 */
@Entity
@Table(name = "tb_pembelian")
public class PembelianEntity implements Serializable {

	private static final long serialVersionUID = -1498718203763831503L;

	@Id
	@GeneratedValue
	@Column(name = "id_pembelian")
	private Long idPembelian;

	@Column(name = "no_po")
	private String nomorPo;

	@Temporal(TemporalType.TIMESTAMP)
	private Date tanggal;

	@Column(name = "is_kirim", nullable = false)
	private boolean kirim;

	private String keterangan;

	@Column(name = "is_pajak", nullable = false)
	private boolean pajak;

	@Column(name = "is_closed", nullable = false)
	private boolean closed;

	@Column(name = "no_ref_kontrak_bl")
	private String nomorKontrakPembelian;

	@Column(name = "tanggal_jatuh_tempo")
	@Temporal(TemporalType.DATE)
	private Date tanggalJatuhTempo;

	@OneToMany(mappedBy = "pembelian", targetEntity = PembelianDetailEntity.class, fetch = FetchType.LAZY)
	private Set<PembelianDetailEntity> pembelianDetails;

	@ManyToOne
	@JoinColumn(name = "id_supplier")
	private SupplierEntity supplier;

	private BigDecimal total;

	private BigDecimal biayaLain;
	
	@Column(name= "created_by")
	private String createdBy;
	
	@Column(name= "created_date")
	@Temporal(TemporalType.TIMESTAMP)
	private Date createdDate;

	public PembelianEntity() {
	}
	
	public PembelianEntity(Long idPembelian, String nomorPo, Date tanggal, boolean kirim, String keterangan, boolean pajak, boolean closed,
			String nomorKontrakPembelian, Date tanggalJatuhTempo, Set<PembelianDetailEntity> pembelianDetails, SupplierEntity supplier, BigDecimal total,
			BigDecimal biayaLain, String createdBy, Date createdDate) {
		this.idPembelian = idPembelian;
		this.nomorPo = nomorPo;
		this.tanggal = tanggal;
		this.kirim = kirim;
		this.keterangan = keterangan;
		this.pajak = pajak;
		this.closed = closed;
		this.nomorKontrakPembelian = nomorKontrakPembelian;
		this.tanggalJatuhTempo = tanggalJatuhTempo;
		this.pembelianDetails = pembelianDetails;
		this.supplier = supplier;
		this.total = total;
		this.biayaLain = biayaLain;
		this.createdBy = createdBy;
		this.createdDate = createdDate;
	}

	public SupplierEntity getSupplier() {
		return supplier;
	}

	public void setSupplier(SupplierEntity supplier) {
		this.supplier = supplier;
	}

	public Long getIdPembelian() {
		return idPembelian;
	}

	public void setIdPembelian(Long idPembelian) {
		this.idPembelian = idPembelian;
	}

	public String getNomorPo() {
		return nomorPo;
	}

	public void setNomorPo(String nomorPo) {
		this.nomorPo = nomorPo;
	}

	public Date getTanggal() {
		return tanggal;
	}

	public void setTanggal(Date tanggal) {
		this.tanggal = tanggal;
	}

	public boolean isKirim() {
		return kirim;
	}

	public void setKirim(boolean kirim) {
		this.kirim = kirim;
	}

	public String getKeterangan() {
		return keterangan;
	}

	public void setKeterangan(String keterangan) {
		this.keterangan = keterangan;
	}

	public boolean isPajak() {
		return pajak;
	}

	public void setPajak(boolean pajak) {
		this.pajak = pajak;
	}

	public boolean isClosed() {
		return closed;
	}

	public void setClosed(boolean closed) {
		this.closed = closed;
	}

	public Set<PembelianDetailEntity> getPembelianDetails() {
		return pembelianDetails;
	}

	public void setPembelianDetails(Set<PembelianDetailEntity> pembelianDetails) {
		this.pembelianDetails = pembelianDetails;
	}

	public void setNomorKontrakPembelian(String nomorKontrakPembelian) {
		this.nomorKontrakPembelian = nomorKontrakPembelian;
	}

	public String getNomorKontrakPembelian() {
		return nomorKontrakPembelian;
	}

	public void setTanggalJatuhTempo(Date tanggalJatuhTempo) {
		this.tanggalJatuhTempo = tanggalJatuhTempo;
	}

	public Date getTanggalJatuhTempo() {
		return tanggalJatuhTempo;
	}

	public BigDecimal getTotal() {
		return total;
	}

	public void setTotal(BigDecimal total) {
		this.total = total;
	}

	public BigDecimal getBiayaLain() {
		return biayaLain;
	}

	public void setBiayaLain(BigDecimal biayaLain) {
		this.biayaLain = biayaLain;
	}

	public void setCreatedBy(String createdBy) {
		this.createdBy = createdBy;
	}

	public String getCreatedBy() {
		return createdBy;
	}

	public void setCreatedDate(Date createdDate) {
		this.createdDate = createdDate;
	}

	public Date getCreatedDate() {
		return createdDate;
	}

}
